package jm.nj.demo13mian.demo08;
/*
* 创建线程的实现类,重写run方法
*
* */
public class RunnableImpl implements Runnable{
    //定义共享票源
    private int ticket = 10;

    @Override
    public void run() {
        //设置死循环,让3个线程买票,重复执行
        while (true){
            if(ticket>0){
                try {
                    Thread.sleep(10);

                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                System.out.println(Thread.currentThread().getName()+"...正在买第"+ticket--+"张票");

            }
        }
    }
}
